package com.kkb.pojo;

import java.util.HashMap;
import java.util.Map;

/**
 * 默认格式的响应返回对象
 * 最后转为JSON字符串格式返回
 */
public class ResponseData {
    private String code = "200";// 默认为200，目前不处理其他状况
    private Boolean success;// 成功调用请求后，是否成功执行的标识
    private String msg;// 描述信息
    private Map<String, Object> data;// 数据

    public ResponseData() {
        this.success = true;
        this.data = new HashMap<>();
    }

    public ResponseData(Boolean success, String msg) {
        this.success = success;
        this.msg = msg;
    }

    public ResponseData(Map<String, Object> data) {
        this.success = true;
        this.data = data;
    }

    public ResponseData(String key, Object value) {
        Map<String, Object> map = new HashMap<>();
        map.put(key, value);
        this.success = true;
        this.data = map;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public Boolean getSuccess() {
        return success;
    }

    public void setSuccess(Boolean success) {
        this.success = success;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Map<String, Object> getData() {
        return data;
    }

    public void setData(Map<String, Object> data) {
        this.data = data;
    }
}
